<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/vue/2.5.18-beta.0/vue.js"></script>
    <style>
        *{margin:0;padding:0}
        .navbar{
            line-height:80px;
            text-align:center;
            background: pink;
            position: fixed;
            width: 100%;
            left:0;
            top:0;
        }
        .content{
            height:2000px;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="navbar":style="filter">导航</div>
        <div class="content">

        </div>
    </div>
    <script>
        new Vue({
            el:"#app",
            data:{
                filter:{
                    opacity:0
                }
            },
            mountend(){
                var self = this;
                window.onscroll = function(){
                    var top = document.documentElement.scrollTop;
                    /* 当top=200是opacity=1 */
                    var opacity = top/200;
                    if(opacity>=1){
                        opacity=1;
                    }
                    self.filter.opacity = opacity;
                }
            }
        })
    </script>
</body>
</html>